package com.wwwc.admin.web.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.SQLException;

import com.wwwc.admin.web.database.*;
import com.wwwc.util.web.*;

public class LeftBarServlet extends HttpServlet {

    public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws IOException, ServletException 
    {
	response.setContentType("text/html");

	String user_ip       = request.getRemoteAddr();
	HttpSession session  = request.getSession(true);
        PrintWriter out      = response.getWriter();

	ResourceBundle SystemInfo = (ResourceBundle)session.getAttribute("SystemInfo");
	
	if (SystemInfo == null) {
	    Locale locale = request.getLocale();
	    SystemInfo = ResourceBundle.getBundle("SystemInfo", locale); 
	    session.setAttribute("SystemInfo", SystemInfo);
	}

	String local_ips = SystemInfo.getString("3wcenter.local_ips");
	if(user_ip==null || !user_ip.startsWith(local_ips)) {
	    return;
	}

	String call_path = request.getContextPath()+request.getServletPath();
	String id = (String)session.getAttribute("id");

	out.println("<TABLE>");
	out.println("<TR><TD><img src='/images/3wccg.jpg' width='95' height='95'></TD></TR>");
	out.println("<TR><TD>&nbsp;</TD></TR>");
	out.println("<TR><TD><A href='logout'><B>Log Off</B></A></TD></TR>");
	out.println("<TR><TD>&nbsp;</TD></TR>");
	
	if(id != null && id.equals("1")) {
	    out.println("<TR><TD>");

	    try {
		RequestDispatcher rd = request.getRequestDispatcher("adminDatabaseManager?who=l");
		rd.include(request,response);
	    }
	    catch (Exception e) {
	    }
	    out.println("</TD></TR>");
	}

	if(id != null && id.equals("2")) {
	    out.println("<TR><TD>");
	    try {
		RequestDispatcher rd = request.getRequestDispatcher("adminUserAccountManager?who=l");
		rd.include(request,response);
	    }
	    catch (Exception e) {
	    }
	    out.println("</TD></TR>");
	}

	if(id != null && id.equals("3")) {
	    out.println("<TR><TD><B>Logs</B></TD></TR>");
	}
	out.println("</TABLE>");
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws IOException, ServletException 
    {
	doPost(request, response);
    }
}








